import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  // 注册路由
  // {
  //   name: '/register',
  //   path: '/register',
  //   component: () => import('@/views/register/index'),
  //   hidden: true
  // },

  // {
  //   path: '/404',
  //   component: () => import('@/views/404'),
  //   hidden: true
  // },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '物业管理系统', icon: 'dashboard' }
    }]
  },

  // {
  //   path: '/sysCount',
  //   component: Layout,
  //   redirect: '/sysCount/count',
  //   name: 'Example',
  //   meta: { title: '人员管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'count',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysCount/list'),
  //       meta: { title: '账号管理', icon: 'table' }
  //     },
  //     {
  //       path: 'sysRole',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysRole/list'),
  //       meta: { title: '角色管理', icon: 'table' }
  //     },
  //     {
  //       path: 'assignAuth',
  //       name: 'Table',

  //       component: () => import('@/views/system/sysRole/assignAuth'),
  //       meta: { title: '分配菜单', icon: 'table' }
  //     },
  //     {
  //       path: 'sysMenu',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysMenu/list'),
  //       meta: { title: '菜单管理', icon: 'table' }
  //     },
  //   ]
  // },
  // {
  //   path: '/sysOwner',
  //   component: Layout,
  //   redirect: '/sysOwner/list',
  //   name: 'Example',
  //   meta: { title: '业主信息管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'list',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysOwner/list'),
  //       meta: { title: '业主信息列表', icon: 'table' }
  //     },
      
     
  //   ]
  // },
  // {
  //   path: '/sysLog',
  //   component: Layout,
  //   redirect: '/sysLog/list',
  //   name: 'Example',
  //   meta: { title: '日志管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'list',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysLog/list'),
  //       meta: { title: '日志列表', icon: 'table' }
  //     },
      
     
  //   ]
  // },
  // {
  //   path:'/sysRepair',
  //   component: Layout,
  //   redirect:'/sysRepair/repair',
  //   name:'Repair',
  //   meta: { title: '服务管理', icon: 'el-icon-s-custom' },
  //   children: [
  //     {

  //       path: 'repair',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysRepair/list'),
  //       meta: { title: '报修管理', icon: 'table' }
  //     },
  //     {

  //       path: 'letter',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysLetter/list'),
  //       meta: { title: '信件管理', icon: 'table' }
  //     },
  //     {

  //       path: 'complaint',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysComplaint/list'),
  //       meta: { title: '投诉管理', icon: 'table' }
  //     },
  //     {

  //       path: 'activity',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysActivity/list'),
  //       meta: { title: '活动管理', icon: 'table' }
  //     },
  //   ]
  // },

  // {
  //   path: '/sysCommunity',
  //   component: Layout,
  //   redirect:'/sysCommunity/community',
  //   name:'Community',
  //   meta: { title: '社区管理', icon: 'el-icon-s-home' },
  //   children: [
  //     {
  //       path: 'community',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysCommunity/list'),
  //       meta: { title: '小区管理', icon: 'table' }
  //     },
  //     {
  //       path: 'build',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysBuild/list'),
  //       meta: { title: '楼栋管理', icon: 'table' }
  //     },
  //     {
  //       path: 'house',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysHouse/list'),
  //       meta: { title: '房屋管理', icon: 'table' }
  //     },
  //   ]
  // },
  // {
  //   path: '/sysParking',
  //   component: Layout,
  //   redirect: '/sysParking/park',
  //   name: 'Example',
  //   meta: { title: '停车管理', icon: 'el-icon-truck' },
  //   children: [
  //     {
  //       path: 'car',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysCar/list'),
  //       meta: { title: '车辆信息', icon: 'table' }
  //     },
  //     {
  //       path: 'parking',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysParking/list'),
  //       meta: { title: '车位信息', icon: 'table' }
  //     },
  //     {
  //       path: 'parkinguse',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysParkingUse/list'),
  //       meta: { title: '车位使用情况', icon: 'table' }
  //     },

  //    ]

  // },
  // {
  //   path: '/sysCharge',
  //   component: Layout,
  //   redirect: '/sysCharge/item',
  //   name: 'Example',
  //   meta: { title: '收费管理', icon: 'el-icon-truck' },
  //   children: [
  //     {
  //       path: 'item',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysCharge/item'),
  //       meta: { title: '收费项目信息', icon: 'table' }
  //     },
  //     {
  //       path: 'detail',
  //       name: 'Table',
  //       component: () => import('@/views/system/sysCharge/detail'),
  //       meta: { title: '收费明细', icon: 'table' }
  //     },

  //    ]

  // },
  // {
  //   path:'/sysMenu',
  //   component: Layout,
  //   redirect:'/sysMenu/list',
  //   meta: {title:'菜单管理',icon:"el-icon-s-operation"},
  //   children:[
  //     {
  //       path:'menu',
  //       name:'menu',
  //       component:() => import('@/views/system/sysMenu/list'),
  //       meta: { title:'菜单管理',icon:'el-icon-s-operation' }
  //     }
  //   ]
  // },


  // { path: '*', redirect: '/404', hidden: true }
]




// {
//   path: '/',
//   component: Layout,
//   redirect: '/example/table',
//   name: 'Example',
//   meta: { title: 'Example', icon: 'el-icon-s-help' },
//   children: [
//     {
//       path: 'table',
//       name: 'Table',
//       component: () => import('@/views/table/index'),
//       meta: { title: 'Table', icon: 'table' }
//     },
//     {
//       path: 'tree',
//       name: 'Tree',
//       component: () => import('@/views/tree/index'),
//       meta: { title: 'Tree', icon: 'tree' }
//     }
//   ]
// },



// 404 page must be placed at the end !!!


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
